package com.uenpay.oem.ui.webview;

import android.text.TextUtils;
import android.webkit.WebView;

import com.qiyunxin.android.http.utils.Utils;
import com.uenpay.im.IMApplication;

/**
 * Created by DELL on 2017/6/20.
 */

public class WebviewPresenter implements WebviewContract.Presenter {

    private  WebviewContract.View mView;

    public WebviewPresenter(WebviewContract.View view) {
        mView = view;
    }
    @Override
    public void onStart() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void loadUrl(WebView webView, String url) {
        boolean isNetworkAvailable = Utils
                .isNetworkConnected(IMApplication.getAppContext());
        if (!isNetworkAvailable) {
            mView.showToast(getString(com.uenpay.im.R.string.no_network));
            return;
        }
        if (TextUtils.isEmpty(url)) {
            url = "https://www.baidu.com/";
        }
        webView.loadUrl(url);
    }

    private String getString(int ResId) {
        return IMApplication.getAppContext().getString(ResId);
    }
}
